package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.R;
import com.zzyl.common.utils.UserThreadLocal;
import com.zzyl.nursing.domain.Reservation;
import com.zzyl.nursing.dto.ReservationDto;
import com.zzyl.nursing.service.MemberReservationService;
import com.zzyl.nursing.vo.ReservationPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 预约信息Controller
 * 
 * @author ruoyi
 */
@Slf4j
@RestController
@RequestMapping("/member/reservation")
@Api(tags =  "预约信息相关接口")
public class MemberReservationController extends BaseController
{
    @Autowired
     private MemberReservationService memberReservationService;
    @GetMapping("/cancelled-count")
    @ApiOperation("查询取消预约数量")
    public R<Integer> getCancelledReservationCount() {
         log.info("查询取消预约数量 {}",UserThreadLocal.getUserId());
        Long userId = UserThreadLocal.getUserId();
        System.out.println("------" + userId);
        return R.ok(1);
    }

    @PostMapping
    @ApiOperation("新增预约")
    public R add(@RequestBody ReservationDto dto) {
        memberReservationService.add(dto);
        return R.ok();
    }

    @GetMapping("/page")
    @ApiOperation("分页查询预约")
    public R<ReservationPage<Reservation>> page(@RequestParam(defaultValue = "1") Integer pageNum,
                                   @RequestParam(defaultValue = "10") Integer pageSize,
                                   @RequestParam(required = false)     Integer status) {

        ReservationPage<Reservation> page =  memberReservationService.page(pageNum,pageSize,status);
        return R.ok(page);
    }

}